var flag;
var label = $("#phoneLabel1");
function log1(str){
    if (str== "" ){
        userAccount.placeholder="手机号不能为空！";
        flag=0;
        document.getElementById("user_phone".placeholder.color="red");
    }
    else{
        var re = /^1\d{10}$/;
        if (!re.test(str)) {
            flag=1;
        }
        else{
            flag=2;
        }
    }
    if(flag==0){
        userAccount.value = "";
        userAccount.placeholder = "手机号不能为空！";
    }
    if(flag==1){
        document.getElementById("phoneLabel1").style.display = "inline";
        $("#phoneLabel1").text("手机号格式错误");

    }
    if(flag==2){
        var username=$("#userAccount").val();
        var password=$("#userPassword").val();
        $.post("/User/LoginServlet", "userAccount="+username+"&userPassword="+password,function (data, status) {
            if(data==0){
                //label.hide();
                document.getElementById("phoneLabel1").style.display = "inline";
                $("#phoneLabel1").text("用户名密码不正确");
            }else if(data ==2){
                document.getElementById("phoneLabel1").style.display = "inline";
                $("#phoneLabel1").text("用户名已在线");
            }else if(data.result== 1){
                if (data.userIdentify==1){
                    if (data.shop == 1) {
                        window.location.href="shopIndex.jsp";
                    }else {
                        window.location.href = "setUs.jsp";
                    }
                }else {
                    window.location.href = "First_Page.jsp";
                }
            }
        },"json");
    }
}
function phone_reset(){
    userAccount.placeholder="请输入手机号";
    document.getElementById("phoneLabel1").style.display = "none";
}

function checkMobile ( str ) {
    document.getElementById("phoneLabel1").style.display = "none";
    if (str== "" ){
        userAccount.placeholder="手机号不能为空！";
        flag=0;
        document.getElementById("user_phone".placeholder.color="red");
    }
}